/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.util.ArrayList;
import org.newdawn.slick.SlickException;

/**
 *
 * @author Sincerelypwnd
 */
public class Projectile extends Entity {

    float damage; //HOw much damage the arrow does
    float speed;
    float rotation;

    public Projectile(float x, float y, String imgLocation, float damage, float speed, float rotation) throws SlickException {
        super(x, y, imgLocation);
        this.damage = damage;
        this.speed = speed;
        this.image.setRotation(rotation);
        this.rotation = rotation;
    }

    public void DoDamage() {
    }

    public void update(int delta) {
        move();
    }

    public void move() {
        x += speed * 0.04f * Math.sin(Math.toRadians(rotation));
        y -= speed * 0.04f * Math.cos(Math.toRadians(rotation));
    }

    public boolean CheckCollision(ArrayList<Enemy> enemies) {
        for (Enemy curEnemy : enemies) {
            if (this.ColliededWith(curEnemy)) {
                curEnemy.DamageDone(damage);
                return true;
            }
        }
        return false;
    }

    public boolean isOffScreen() {
        if (x > 900 || x < -50) {
            return true;
        } else {
            return false;
        }
    }
}
